package com.miaosha.ms_02.controller;

import com.miaosha.ms_02.result.CodeMsg;
import com.miaosha.ms_02.result.Result;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class DemoController {

    @RequestMapping("/hello")
    public String hello(Model model){
        model.addAttribute("name","张三");
        return "index";
    }

    @RequestMapping("/success")
    @ResponseBody
    public Result<String> getSuccess(){
        return  Result.success("233333");
    }

    @RequestMapping("/err")
    @ResponseBody
    public Result<String> getErr(){
        return Result.error(CodeMsg.SERVER_ERR);
    }
}
